﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CommHelper
{
    /// <summary>
    /// 窗体样式帮助类
    /// </summary>
    public class FormStyleHelper
    {
        private const int CS_DropSHADOW = 0x20000;
        private const int GCL_STYLE = (-26);

        [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
        public static extern int SetClassLong(IntPtr hwnd, int nIndex, int dwNewLong);
        [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
        public static extern int GetClassLong(IntPtr hwnd, int nIndex);

        /// <summary>
        /// 设置窗体阴影
        /// </summary>
        /// <param name="Handle">窗体句柄</param>
        public static void SetFormShadow(IntPtr Handle)
        {
            SetClassLong(Handle, GCL_STYLE, GetClassLong(Handle, GCL_STYLE) | CS_DropSHADOW);
        }
    }
}
